Conditions | 3 |
Total Lines | 59 |
Code Lines | 54 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | import React from 'react'; |
||
42 | |||
43 | render() { |
||
44 | const value = this.state.value || defaultCondition; // default |
||
45 | return ( |
||
46 | <div className="date-range-selector-container"> |
||
47 | <div className="selector-item"> |
||
48 | <ButtonToolbar className="selector-comparator"> |
||
49 | <ButtonGroup> |
||
50 | <OverlayTrigger placement="top" overlay={<Tooltip>모든 범위</Tooltip>}> |
||
51 | <Button |
||
52 | active={value.comparator === '*'} |
||
53 | onClick={() => this.onDateChanged({ comparator: '*' })} |
||
54 | disabled={this.props.disabled} |
||
55 | > |
||
56 | ✱ {/* asterisk */} |
||
57 | </Button> |
||
58 | </OverlayTrigger> |
||
59 | <OverlayTrigger placement="top" overlay={<Tooltip>범위 지정</Tooltip>}> |
||
60 | <Button |
||
61 | active={value.comparator === '~'} |
||
62 | onClick={() => this.onDateChanged({ comparator: '~' })} |
||
63 | disabled={this.props.disabled} |
||
64 | > |
||
65 | ∼ {/* tilda */} |
||
66 | </Button> |
||
67 | </OverlayTrigger> |
||
68 | </ButtonGroup> |
||
69 | </ButtonToolbar> |
||
70 | <FormControl |
||
71 | className="selector-inputs" |
||
72 | type="text" |
||
73 | value={'모든 기간 대상'} |
||
74 | style={value.comparator !== '*' ? { display: 'none' } : {}} |
||
75 | readOnly |
||
76 | /> |
||
77 | <div className="selector-inputs-container" style={value.comparator !== '~' ? { display: 'none' } : {}}> |
||
78 | <DateTime |
||
79 | className="selector-inputs" |
||
80 | value={value.startTime} |
||
81 | inputProps={{ placeholder: '시작 일시' }} |
||
82 | dateFormat={dateFormat} |
||
83 | timeFormat={timeFormat} |
||
84 | onChange={startTime => this.onDateChanged({ startTime })} |
||
85 | disabled={this.props.disabled} |
||
86 | closeOnSelect |
||
87 | /> |
||
88 | <DateTime |
||
89 | className="selector-inputs selector-inputs-second" |
||
90 | value={value.endTime} |
||
91 | inputProps={{ placeholder: '종료 일시' }} |
||
92 | dateFormat={dateFormat} |
||
93 | timeFormat={timeFormat} |
||
94 | onChange={endTime => this.onDateChanged({ endTime })} |
||
95 | disabled={this.props.disabled} |
||
96 | closeOnSelect |
||
97 | /> |
||
98 | </div> |
||
99 | </div> |
||
100 | </div> |
||
101 | ); |
||
114 |